﻿Imports System.Data.SqlClient

Public Class clsPERIODOS
    Public Sub Insertar(ByVal PERIODO As Integer, ByVal INICIAL As Date, ByVal FINAL As Date)
        Dim sql As String = "Insert Into PERIODOS " & _
                              "VALUES (" & _
                            "@PERIODO," & _
                            "@FECHAINICIAL," & _
                            "@FECHAFINAL," & _
                            "@PAGADO," & _
                            "@TERMINADO)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("PERIODO", PERIODO)
        Command.Parameters.AddWithValue("FECHAINICIAL", INICIAL)
        Command.Parameters.AddWithValue("FECHAFINAL", FINAL)
        Command.Parameters.AddWithValue("PAGADO", 0)
        Command.Parameters.AddWithValue("TERMINADO", 0)
        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
            If RowsAffected > 0 Then
                cnConn.Close()
            Else
                If cnConn.State = ConnectionState.Open Then
                    cnConn.Close()
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
        End Try


    End Sub
End Class
